package com.tbb.app.base.entity;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.TableName;
import com.tbb.app.base.dto.NoteAddDTO;
import com.tbb.app.common.entity.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * 笔记表
 *
 * @author Liu
 * @since 2022-01-11
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tbb_note")
public class Note extends BaseEntity<Note> {

    /**
     * 标题
     */
    private String title;

    /**
     * 频道id
     */
    private String channelId;

    /**
     * 正文
     */
    private String text;

    /**
     * 图片urls
     */
    private String imgs;

    /**
     * 是否发布，0-草稿，1-已发布
     */
    private Boolean isPublish;

    /**
     * 点赞数
     */
    private Integer likeNum;

    /**
     * 收藏数
     */
    private Integer collectNum;

    /**
     * 评论数
     */
    private Integer remarkNum;

    /**
     * 作者id
     */
    private String userId;

    public Note(NoteAddDTO dto) {
        this.title = dto.getTitle();
        this.text = dto.getText();
        this.channelId = dto.getChannelId();
        this.imgs = JSON.toJSONString(dto.getImgs());
    }


}
